home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / gnu / emacs.lha / emacs-19.16 / lisp / lucid.el < prev    next >
Lisp/Scheme  |  1993-06-01  |  7KB  |  191 lines

  1. ;;; lucid.el --- Emulate some Lucid Emacs functions.
  2. ;; Copyright (C) 1993 Free Software Foundation, Inc.
  3.  
  4. ;; This file is part of GNU Emacs.
  5.  
  6. ;; GNU Emacs is free software; you can redistribute it and/or modify
  7. ;; it under the terms of the GNU General Public License as published by
  8. ;; the Free Software Foundation; either version 2, or (at your option)
  9. ;; any later version.
  10.  
  11. ;; GNU Emacs is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. ;; GNU General Public License for more details.
  15.  
  16. ;; You should have received a copy of the GNU General Public License
  17. ;; along with GNU Emacs; see the file COPYING.  If not, write to
  18. ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  19.  
  20.  
  21. (defun add-timeout (secs function object &optional resignal)
  22.   (run-at-time secs resignal function object))
  23.  
  24. (defun disable-timeout (timeout)
  25.   (cancel-timer timeout))
  26.  
  27. (defun copy-tree (tree)
  28.   (if (consp tree)
  29.       (cons (copy-tree (car tree))
  30.         (copy-tree (cdr tree)))
  31.     (if (vectorp tree)
  32.     (let* ((new (copy-sequence tree))
  33.            (i (1- (length new))))
  34.       (while (>= i 0)
  35.         (aset new i (copy-tree (aref new i)))
  36.         (setq i (1- i)))
  37.       new)
  38.       tree)))
  39.  
  40. (defalias 'current-time-seconds 'current-time)
  41.  
  42. (defun keymap-parent (keymap)
  43.   (let ((tail (cdr keymap)))
  44.     (while (and tail (not (eq (car tail) 'keymap)))
  45.       (setq tail (cdr tail)))
  46.     tail))
  47.  
  48. (defun set-keymap-parent (keymap new-parent)
  49.   (let ((tail (cdr keymap)))
  50.     (while (and tail (cdr tail) (not (eq (car (cdr tail)) 'keymap)))
  51.       (setq tail (cdr tail)))
  52.     (if tail
  53.     (setcdr tail new-parent))))
  54.  
  55. (defun remove-hook (hook-var function)
  56.   (if (boundp 'hook-var)
  57.       (set hook-var (delq function (symbol-value hook-var)))))
  58.  
  59. (defun remprop (symbol prop)
  60.   (let ((plist (symbol-plist symbol)))
  61.     (while (eq (car plist) prop)
  62.       (setplist symbol (setq plist (cdr (cdr plist)))))
  63.     (while plist
  64.       (if (eq (nth 2 plist) prop)
  65.       (setcdr (cdr plist) (nthcdr 4 plist)))
  66.       (setq plist (cdr (cdr plist))))))
  67.  
  68. (defun map-keymap (function keymap &optional sort-first)
  69.   "Call FUNCTION for every binding in KEYMAP.
  70. This includes bindings inherited from a parent keymap.
  71. FUNCTION receives two arguments each time it is called:
  72. the character (more generally, the event type) that is bound,
  73. and the binding it has.
  74.  
  75. Note that passing the event type directly to `define-key' does not work
  76. in Emacs 19.  We do not emulate that particular feature of Lucid Emacs.
  77. If your code does that, modify it to make a vector containing the event
  78. type that you get.  That will work in both versions of Emacs."
  79.   (if sort-first
  80.       (let (list)
  81.     (map-keymap (function (lambda (a b)
  82.                 (setq list (cons (cons a b) list))))
  83.             keymap)
  84.     (setq list (sort list
  85.              (function (lambda (a b)
  86.                      (setq a (car a) b (car b))
  87.                      (if (integerp a)
  88.                      (if (integerp b) (< a b)
  89.                        t)
  90.                        (if (integerp b) t
  91.                      (string< a b)))))))
  92.     (while list
  93.       (funcall function (car (car list)) (cdr (car list)))
  94.       (setq list (cdr list))))
  95.     (while (consp keymap)
  96.       (if (consp (car keymap))
  97.       (funcall function (car (car keymap)) (cdr (car keymap)))
  98.     (if (vectorp (car keymap))
  99.         (let ((i (1- (length (car keymap))))
  100.           (vector (car keymap)))
  101.           (while (>= i 0)
  102.         (funcall function i (aref vector i))
  103.         (setq i (1- i))))))
  104.       (setq keymap (cdr keymap)))))
  105.  
  106. (defun real-path-name (name &optional default)
  107.   (file-truename (expand-file-name name default)))
  108.  
  109. ;; It's not clear what to return if the mouse is not in FRAME.
  110. (defun read-mouse-position (frame)
  111.   (let ((pos (mouse-position)))
  112.     (if (eq (car pos) frame)
  113.     (cdr pos))))
  114.  
  115. (defun switch-to-other-buffer (arg)
  116.   "Switch to the previous buffer.
  117. With a numeric arg N, switch to the Nth most recent buffer.
  118. With an arg of 0, buries the current buffer at the
  119. bottom of the buffer stack."
  120.   (interactive "p")
  121.   (if (eq arg 0)
  122.       (bury-buffer (current-buffer)))
  123.   (switch-to-buffer
  124.    (if (<= arg 1) (other-buffer (current-buffer))
  125.      (nth (1+ arg)
  126.       (apply 'nconc
  127.          (mapcar
  128.           (lambda (buf)
  129.             (if (= ?\  (string-to-char (buffer-name buf)))
  130.             nil
  131.               (list buf)))
  132.           (buffer-list)))))))
  133.  
  134. (defalias 'find-face 'internal-find-face)
  135. (defalias 'get-face 'internal-get-face)
  136. (defalias 'try-face-font 'internal-try-face-font)
  137.  
  138. ;; Support the Lucid names with `screen' instead of `frame'.
  139.  
  140. (defalias 'current-screen-configuration 'current-frame-configuration)
  141. (defalias 'delete-screen 'delete-frame)
  142. (defalias 'find-file-new-screen 'find-file-other-frame)
  143. (defalias 'find-file-read-only-new-screen 'find-file-read-only-other-frame)
  144. (defalias 'find-tag-new-screen 'find-tag-other-frame)
  145. ;;(defalias 'focus-screen 'focus-frame)
  146. (defalias 'iconify-screen 'iconify-frame)
  147. (defalias 'mail-new-screen 'mail-other-frame)
  148. (defalias 'make-screen-invisible 'make-frame-invisible)
  149. (defalias 'make-screen-visible 'make-frame-visible)
  150. ;; (defalias 'minibuffer-screen-list 'minibuffer-frame-list)
  151. (defalias 'modify-screen-parameters 'modify-frame-parameters)
  152. (defalias 'next-screen 'next-frame)
  153. ;; (defalias 'next-multiscreen-window 'next-multiframe-window)
  154. ;; (defalias 'previous-multiscreen-window 'previous-multiframe-window)
  155. ;; (defalias 'redirect-screen-focus 'redirect-frame-focus)
  156. (defalias 'redraw-screen 'redraw-frame)
  157. ;; (defalias 'screen-char-height 'frame-char-height)
  158. ;; (defalias 'screen-char-width 'frame-char-width)
  159. ;; (defalias 'screen-configuration-to-register 'frame-configuration-to-register)
  160. ;; (defalias 'screen-focus 'frame-focus)
  161. (defalias 'screen-height 'frame-height)
  162. (defalias 'screen-list 'frame-list)
  163. ;; (defalias 'screen-live-p 'frame-live-p)
  164. (defalias 'screen-parameters 'frame-parameters)
  165. (defalias 'screen-pixel-height 'frame-pixel-height)
  166. (defalias 'screen-pixel-width 'frame-pixel-width)
  167. (defalias 'screen-root-window 'frame-root-window)
  168. (defalias 'screen-selected-window 'frame-selected-window)
  169. (defalias 'lower-screen 'lower-frame)
  170. (defalias 'raise-screen 'raise-frame)
  171. (defalias 'screen-visible-p 'frame-visible-p)
  172. (defalias 'screen-width 'frame-width)
  173. (defalias 'screenp 'framep)
  174. (defalias 'select-screen 'select-frame)
  175. (defalias 'selected-screen 'selected-frame)
  176. ;; (defalias 'set-screen-configuration 'set-frame-configuration)
  177. ;; (defalias 'set-screen-height 'set-frame-height)
  178. (defalias 'set-screen-position 'set-frame-position)
  179. (defalias 'set-screen-size 'set-frame-size)
  180. ;; (defalias 'set-screen-width 'set-frame-width)
  181. (defalias 'switch-to-buffer-new-screen 'switch-to-buffer-other-frame)
  182. ;; (defalias 'unfocus-screen 'unfocus-frame)
  183. (defalias 'visible-screen-list 'visible-frame-list)
  184. (defalias 'window-screen 'window-frame)
  185. (defalias 'x-create-screen 'x-create-frame)
  186. (defalias 'x-new-screen 'new-frame)
  187.  
  188. (provide 'lucid)
  189.  
  190. ;;; end of lucid.el
  191.